import React, { Component } from 'react'
import {Modal, Toast} from 'antd-mobile';
import {post} from '../../Lib/Http';
import apiUrl from '../../Config/web';

class AppRecharge extends Component {
    
    constructor(props){
        super(props);

        this.state = {
            form:''
        }
    }

    componentDidMount() {
        
        let that = this;

        let parmasData = this.props.match.params;

        console.log(parmasData);

        Toast.loading('loading...', 10);

        post(apiUrl.app_order, {
            id:parmasData.id
        }, function(success){

            Toast.hide();
            console.log(success);

            if(success.status !== 200){
                return;
            }

            if(success.data.code === 1000){
                that.props.history.push('/login');
                console.log('login');
                return;
            }

            that.setState({
                form:success.data
            });

            document.forms['alipaysubmit'].submit();

            return;


        }, function(error){
            Toast.hide();

            console.log(error);
        });


    }


    render() {

        let parmasData = this.props.match;

        return (
            <div style={{'display':'none'}} dangerouslySetInnerHTML={{__html:this.state.form}}></div>
        );
    }
}

export default AppRecharge;